DROP TABLE CRST_AR_RECEIVABLE_APPLICATION;
      
CREATE TABLE CRST_AR_RECEIVABLE_APPLICATION                                                                                                            
(                                                                                                                                                            
  RECEIVABLE_APPLICATION_ID       NUMBER(15)    NOT NULL,                                                                                                    
  LAST_UPDATED_BY                 NUMBER(15)    NOT NULL,                                                                                                    
  LAST_UPDATE_DATE                DATE          NOT NULL,                                                                                                    
  CREATED_BY                      NUMBER(15)    NOT NULL,                                                                                                    
  CREATION_DATE                   DATE          NOT NULL,                                                                                                    
  AMOUNT_APPLIED                  NUMBER        NOT NULL,                                                                                                    
  AMOUNT_APPLIED_FROM             NUMBER,                                                                                                                    
  TRANS_TO_RECEIPT_RATE           NUMBER,                                                                                                                    
  GL_DATE                         DATE          NOT NULL,                                                                                                    
  CODE_COMBINATION_ID             NUMBER(15)    NOT NULL,                                                                                                    
  SET_OF_BOOKS_ID                 NUMBER(15)    NOT NULL,                                                                                                    
  DISPLAY                         VARCHAR2(1 BYTE) NOT NULL,                                                                                                 
  APPLY_DATE                      DATE          NOT NULL,                                                                                                    
  APPLICATION_TYPE                VARCHAR2(20 BYTE) NOT NULL,                                                                                                
  STATUS                          VARCHAR2(30 BYTE) NOT NULL,                                                                                                
  PAYMENT_SCHEDULE_ID             NUMBER(15)    NOT NULL,                                                                                                    
  LAST_UPDATE_LOGIN               NUMBER(15),                                                                                                                
  CASH_RECEIPT_ID                 NUMBER(15),                                                                                                                
  APPLIED_CUSTOMER_TRX_ID         NUMBER(15),                                                                                                                
  APPLIED_CUSTOMER_TRX_LINE_ID    NUMBER(15),                                                                                                                
  APPLIED_PAYMENT_SCHEDULE_ID     NUMBER(15),                                                                                                                
  CUSTOMER_TRX_ID                 NUMBER(15),                                                                                                                
  LINE_APPLIED                    NUMBER,                                                                                                                    
  TAX_APPLIED                     NUMBER,                                                                                                                    
  FREIGHT_APPLIED                 NUMBER,                                                                                                                    
  RECEIVABLES_CHARGES_APPLIED     NUMBER,                                                                                                                    
  EARNED_DISCOUNT_TAKEN           NUMBER,                                                                                                                    
  UNEARNED_DISCOUNT_TAKEN         NUMBER,                                                                                                                    
  DAYS_LATE                       NUMBER(15),                                                                                                                
  APPLICATION_RULE                VARCHAR2(30 BYTE) NOT NULL,                                                                                                
  GL_POSTED_DATE                  DATE,                                                                                                                      
  COMMENTS                        VARCHAR2(240 BYTE),                                                                                                        
  ATTRIBUTE_CATEGORY              VARCHAR2(30 BYTE),                                                                                                         
  ATTRIBUTE1                      VARCHAR2(150 BYTE),                                                                                                        
  ATTRIBUTE2                      VARCHAR2(150 BYTE),                                                                                                        
  ATTRIBUTE3                      VARCHAR2(150 BYTE),                                                                                                        
  ATTRIBUTE4                      VARCHAR2(150 BYTE),                                                                                                        
  ATTRIBUTE5                      VARCHAR2(150 BYTE),                                                                                                        
  ATTRIBUTE6                      VARCHAR2(150 BYTE),                                                                                                        
  ATTRIBUTE7                      VARCHAR2(150 BYTE),                                                                                                        
  ATTRIBUTE8                      VARCHAR2(150 BYTE),                                                                                                        
  ATTRIBUTE9                      VARCHAR2(150 BYTE),                                                                                                        
  ATTRIBUTE10                     VARCHAR2(150 BYTE),                                                                                                        
  POSTABLE                        VARCHAR2(1 BYTE),                                                                                                          
  POSTING_CONTROL_ID              NUMBER(15)    DEFAULT -3                    NOT NULL,                                                                      
  ACCTD_AMOUNT_APPLIED_FROM       NUMBER        NOT NULL,                                                                                                    
  ACCTD_AMOUNT_APPLIED_TO         NUMBER,                                                                                                                    
  ACCTD_EARNED_DISCOUNT_TAKEN     NUMBER,                                                                                                                    
  ATTRIBUTE11                     VARCHAR2(150 BYTE),                                                                                                        
  ATTRIBUTE12                     VARCHAR2(150 BYTE),                                                                                                        
  ATTRIBUTE13                     VARCHAR2(150 BYTE),                                                                                                        
  ATTRIBUTE14                     VARCHAR2(150 BYTE),                                                                                                        
  ATTRIBUTE15                     VARCHAR2(150 BYTE),                                                                                                        
  CONFIRMED_FLAG                  VARCHAR2(1 BYTE),                                                                                                          
  PROGRAM_APPLICATION_ID          NUMBER(15),                                                                                                                
  PROGRAM_ID                      NUMBER(15),                                                                                                                
  PROGRAM_UPDATE_DATE             DATE,                                                                                                                      
  REQUEST_ID                      NUMBER(15),                                                                                                                
  USSGL_TRANSACTION_CODE          VARCHAR2(30 BYTE),                                                                                                         
  USSGL_TRANSACTION_CODE_CONTEXT  VARCHAR2(30 BYTE),                                                                                                         
  EARNED_DISCOUNT_CCID            NUMBER(15),                                                                                                                
  UNEARNED_DISCOUNT_CCID          NUMBER(15),                                                                                                                
  ACCTD_UNEARNED_DISCOUNT_TAKEN   NUMBER,                                                                                                                    
  REVERSAL_GL_DATE                DATE,                                                                                                                      
  CASH_RECEIPT_HISTORY_ID         NUMBER(15),                                                                                                                
  ORG_ID                          NUMBER(15),
  TAX_CODE                        VARCHAR2(50 BYTE),                                                                                                         
  GLOBAL_ATTRIBUTE1               VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE2               VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE3               VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE4               VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE5               VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE6               VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE7               VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE8               VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE9               VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE10              VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE11              VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE12              VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE13              VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE14              VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE15              VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE16              VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE17              VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE18              VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE19              VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE20              VARCHAR2(150 BYTE),                                                                                                        
  GLOBAL_ATTRIBUTE_CATEGORY       VARCHAR2(30 BYTE),                                                                                                         
  CONS_INV_ID                     NUMBER(15),                                                                                                                
  CONS_INV_ID_TO                  NUMBER(15),                                                                                                                
  RULE_SET_ID                     NUMBER,                                                                                                                    
  LINE_EDISCOUNTED                NUMBER,                                                                                                                    
  TAX_EDISCOUNTED                 NUMBER,                                                                                                                    
  FREIGHT_EDISCOUNTED             NUMBER,                                                                                                                    
  CHARGES_EDISCOUNTED             NUMBER,                                                                                                                    
  LINE_UEDISCOUNTED               NUMBER,                                                                                                                    
  TAX_UEDISCOUNTED                NUMBER,                                                                                                                    
  FREIGHT_UEDISCOUNTED            NUMBER,                                                                                                                    
  CHARGES_UEDISCOUNTED            NUMBER,                                                                                                                    
  RECEIVABLES_TRX_ID              NUMBER(15),                                                                                                                
  ON_ACCOUNT_CUSTOMER             NUMBER(15),                                                                                                                
  MRC_AMOUNT_APPLIED              VARCHAR2(2000 BYTE),                                                                                                       
  MRC_AMOUNT_APPLIED_FROM         VARCHAR2(2000 BYTE),                                                                                                       
  MRC_DISPLAY                     VARCHAR2(2000 BYTE),                                                                                                       
  MRC_STATUS                      VARCHAR2(2000 BYTE),                                                                                                       
  MRC_PAYMENT_SCHEDULE_ID         VARCHAR2(2000 BYTE),                                                                                                       
  MRC_CASH_RECEIPT_ID             VARCHAR2(2000 BYTE),                                                                                                       
  MRC_GL_POSTED_DATE              VARCHAR2(2000 BYTE),                                                                                                       
  MRC_POSTING_CONTROL_ID          VARCHAR2(2000 BYTE),                                                                                                       
  MRC_ACCTD_AMOUNT_APPLIED_FROM   VARCHAR2(2000 BYTE),                                                                                                       
  MRC_ACCTD_AMOUNT_APPLIED_TO     VARCHAR2(2000 BYTE),                                                                                                       
  MRC_ACCTD_EARNED_DISC_TAKEN     VARCHAR2(2000 BYTE),                                                                                                       
  MRC_ACCTD_UNEARNED_DISC_TAKEN   VARCHAR2(2000 BYTE),                                                                                                       
  EDISC_TAX_ACCT_RULE             VARCHAR2(3 BYTE),                                                                                                          
  UNEDISC_TAX_ACCT_RULE           VARCHAR2(3 BYTE),                                                                                                          
  LINK_TO_TRX_HIST_ID             NUMBER(15),                                                                                                                
  LINK_TO_CUSTOMER_TRX_ID         NUMBER(15),                                                                                                                
  APPLICATION_REF_TYPE            VARCHAR2(30 BYTE),                                                                                                         
  APPLICATION_REF_ID              NUMBER(15),                                                                                                                
  APPLICATION_REF_NUM             VARCHAR2(30 BYTE),                                                                                                         
  CHARGEBACK_CUSTOMER_TRX_ID      NUMBER(15),                                                                                                                
  SECONDARY_APPLICATION_REF_ID    NUMBER(15),                                                                                                                
  PAYMENT_SET_ID                  NUMBER(15),                                                                                                                
  APPLICATION_REF_REASON          VARCHAR2(30 BYTE),                                                                                                         
  CUSTOMER_REFERENCE              VARCHAR2(100 BYTE),
  RECEIVABLE_APPLICATION_ID_N     NUMBER(15)                                                                                                         
);
